//
//  AdventureDetail_CollectionViewCell.m
//  Food
//
//  Created by dlios on 15-7-15.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "AdventureDetail_CollectionViewCell.h"
#import "UIImageView+WebCache.h"

@implementation AdventureDetail_CollectionViewCell
- (void)dealloc
{
    [_recommmendImage release];
    [_name release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.recommmendImage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.recommmendImage];
        
        self.name = [[UILabel alloc] init];
        [self.name setTextAlignment:NSTextAlignmentCenter];
        //self.name.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:self.name];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.recommmendImage.frame = CGRectMake(0, 0, layoutAttributes.size.width, layoutAttributes.size.height - 20);
    self.name.frame = CGRectMake(0 , self.recommmendImage.frame.size.height, self.recommmendImage.frame.size.width, 30);
}

- (void)setRecommendModel:(AdventureDetail_Recommend_Model *)recommendModel
{
    if (_recommendModel != recommendModel) {
        [_recommendModel release];
        _recommendModel = [recommendModel retain];
    }
    [self.recommmendImage sd_setImageWithURL:[NSURL URLWithString:recommendModel.imagePathThumbnails]];
    self.name.text = recommendModel.name;
}
@end
